#pragma once

#include <sys/socket.h>
#include <string>
#include "socket.h"

// 继承自父类CSocket的子类
class CLogicSocket: public CSocket{
public:
    CLogicSocket();
    virtual ~CLogicSocket();
    virtual bool Initialize();

    // 通用收发数据相关函数（发送没有包体的包给客户端）
    void  SendNoBodyPkgToClient(LPSTRUC_MSG_HEADER pMsgHeader,unsigned short iMsgCode);
    void  SendLogicPkgToClient(std::string data,int fd);

    // 各种业务逻辑相关函数
    bool _HandlePress(lpconnection_t pConn, LPSTRUC_MSG_HEADER pMsgHeader, char *pPkgBody, unsigned short iBodyLength);
    //bool _HandleRegister(lpconnection_t pConn,LPSTRUC_MSG_HEADER pMsgHeader,char *pPkgBody,unsigned short iBodyLength);
    //bool _HandleLogIn(lpconnection_t pConn,LPSTRUC_MSG_HEADER pMsgHeader,char *pPkgBody,unsigned short iBodyLength);
    bool _HandleLogic(lpconnection_t pConn,LPSTRUC_MSG_HEADER pMsgHeader,char *pPkgBody,unsigned short iBodyLength);
    // 心跳包
    bool _HandlePing(lpconnection_t pConn,LPSTRUC_MSG_HEADER pMsgHeader,char *pPkgBody,unsigned short iBodyLength);

    // 心跳包检测时间到，该去检测心跳包是否超时的事宜，子类继承重写
    virtual void ProcPingTimeOutChecking(LPSTRUC_MSG_HEADER tmpmsg,time_t cur_time);
    // 处理客户端请求（收到的包），虚函数，子类继承基类并重写
    virtual void ThreadRecvProcFunc(char *pMsgBuf);
};